package com.sch.sudoku;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import android.view.Display;
import android.view.WindowManager;
import android.widget.Button;
import android.view.Menu;
import android.widget.LinearLayout;
import android.view.View;

public class game extends Activity
{
	Button[][] button_table = new Button[9][9];
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO: Implement this method
		super.onCreate(savedInstanceState);
		setContentView(R.layout.game);
		getWindow().setStatusBarColor(0xFF3F51B5);
		setTitle("game");
		check_resolution();
		make_button_table();
		setup_button();
		make_layout_table();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		menu.add(0,0,0,"关于");
		menu.add(0,0,1,"退出");
		return true;
	}
	
	public void alert(Object message)
	{
		Toast.makeText(this,String.valueOf(message),Toast.LENGTH_SHORT).show();
	}
	public void check_resolution()//检查分辨率
	{
		Display d = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
		int w = d.getWidth();
		int h = d.getHeight();
		if(h > w)
			{
			if(w == 1440)
			{
				alert(String.valueOf(w)+"*"+String.valueOf(h));
			}
			else if(w == 1080)
			{
				alert(String.valueOf(w)+"*"+String.valueOf(h));
			}
			else if(w == 720)
			{
				alert(String.valueOf(w)+"*"+String.valueOf(h));
			}
			else if(w == 240)
			{
				alert(String.valueOf(w)+"*"+String.valueOf(h));
			}
			else
			{
				alert("不支持的分辨率：" + String.valueOf(w) + "*" + String.valueOf(h));
				try
				{
					new Thread().sleep(3);
					finishAndRemoveTask();
				}
				catch(Exception e)
				{
					alert(e.getMessage());
				}
			}
		}
		else
		{
			alert("不支持的分辨率：" + String.valueOf(w) + "*" + String.valueOf(h));
			try
			{
				new Thread().sleep(3);
				finishAndRemoveTask();
			}
			catch(Exception e)
			{
				alert(e.getMessage());
			}
		}
	}
	public void make_button_table()
	{
		button_table[0][0] = (Button)findViewById(R.id.gameButton11);
		button_table[0][1] = (Button)findViewById(R.id.gameButton12);
		button_table[0][2] = (Button)findViewById(R.id.gameButton13);
		button_table[0][3] = (Button)findViewById(R.id.gameButton14);
		button_table[0][4] = (Button)findViewById(R.id.gameButton15);
		button_table[0][5] = (Button)findViewById(R.id.gameButton16);
		button_table[0][6] = (Button)findViewById(R.id.gameButton17);
		button_table[0][7] = (Button)findViewById(R.id.gameButton18);
		button_table[0][8] = (Button)findViewById(R.id.gameButton19);
		button_table[1][0] = (Button)findViewById(R.id.gameButton21);
		button_table[1][1] = (Button)findViewById(R.id.gameButton22);
		button_table[1][2] = (Button)findViewById(R.id.gameButton23);
		button_table[1][3] = (Button)findViewById(R.id.gameButton24);
		button_table[1][4] = (Button)findViewById(R.id.gameButton25);
		button_table[1][5] = (Button)findViewById(R.id.gameButton26);
		button_table[1][6] = (Button)findViewById(R.id.gameButton27);
		button_table[1][7] = (Button)findViewById(R.id.gameButton28);
		button_table[1][8] = (Button)findViewById(R.id.gameButton29);
		button_table[2][0] = (Button)findViewById(R.id.gameButton31);
		button_table[2][1] = (Button)findViewById(R.id.gameButton32);
		button_table[2][2] = (Button)findViewById(R.id.gameButton33);
		button_table[2][3] = (Button)findViewById(R.id.gameButton34);
		button_table[2][4] = (Button)findViewById(R.id.gameButton35);
		button_table[2][5] = (Button)findViewById(R.id.gameButton36);
		button_table[2][6] = (Button)findViewById(R.id.gameButton37);
		button_table[2][7] = (Button)findViewById(R.id.gameButton38);
		button_table[2][8] = (Button)findViewById(R.id.gameButton39);
		button_table[3][0] = (Button)findViewById(R.id.gameButton41);
		button_table[3][1] = (Button)findViewById(R.id.gameButton42);
		button_table[3][2] = (Button)findViewById(R.id.gameButton43);
		button_table[3][3] = (Button)findViewById(R.id.gameButton44);
		button_table[3][4] = (Button)findViewById(R.id.gameButton45);
		button_table[3][5] = (Button)findViewById(R.id.gameButton46);
		button_table[3][6] = (Button)findViewById(R.id.gameButton47);
		button_table[3][7] = (Button)findViewById(R.id.gameButton48);
		button_table[3][8] = (Button)findViewById(R.id.gameButton49);
		button_table[4][0] = (Button)findViewById(R.id.gameButton51);
		button_table[4][1] = (Button)findViewById(R.id.gameButton52);
		button_table[4][2] = (Button)findViewById(R.id.gameButton53);
		button_table[4][3] = (Button)findViewById(R.id.gameButton54);
		button_table[4][4] = (Button)findViewById(R.id.gameButton55);
		button_table[4][5] = (Button)findViewById(R.id.gameButton56);
		button_table[4][6] = (Button)findViewById(R.id.gameButton57);
		button_table[4][7] = (Button)findViewById(R.id.gameButton58);
		button_table[4][8] = (Button)findViewById(R.id.gameButton59);
		button_table[5][0] = (Button)findViewById(R.id.gameButton61);
		button_table[5][1] = (Button)findViewById(R.id.gameButton62);
		button_table[5][2] = (Button)findViewById(R.id.gameButton63);
		button_table[5][3] = (Button)findViewById(R.id.gameButton64);
		button_table[5][4] = (Button)findViewById(R.id.gameButton65);
		button_table[5][5] = (Button)findViewById(R.id.gameButton66);
		button_table[5][6] = (Button)findViewById(R.id.gameButton67);
		button_table[5][7] = (Button)findViewById(R.id.gameButton68);
		button_table[5][8] = (Button)findViewById(R.id.gameButton69);
		button_table[6][0] = (Button)findViewById(R.id.gameButton71);
		button_table[6][1] = (Button)findViewById(R.id.gameButton72);
		button_table[6][2] = (Button)findViewById(R.id.gameButton73);
		button_table[6][3] = (Button)findViewById(R.id.gameButton74);
		button_table[6][4] = (Button)findViewById(R.id.gameButton75);
		button_table[6][5] = (Button)findViewById(R.id.gameButton76);
		button_table[6][6] = (Button)findViewById(R.id.gameButton77);
		button_table[6][7] = (Button)findViewById(R.id.gameButton78);
		button_table[6][8] = (Button)findViewById(R.id.gameButton79);
		button_table[7][0] = (Button)findViewById(R.id.gameButton81);
		button_table[7][1] = (Button)findViewById(R.id.gameButton82);
		button_table[7][2] = (Button)findViewById(R.id.gameButton83);
		button_table[7][3] = (Button)findViewById(R.id.gameButton84);
		button_table[7][4] = (Button)findViewById(R.id.gameButton85);
		button_table[7][5] = (Button)findViewById(R.id.gameButton86);
		button_table[7][6] = (Button)findViewById(R.id.gameButton87);
		button_table[7][7] = (Button)findViewById(R.id.gameButton88);
		button_table[7][8] = (Button)findViewById(R.id.gameButton89);
		button_table[8][0] = (Button)findViewById(R.id.gameButton91);
		button_table[8][1] = (Button)findViewById(R.id.gameButton92);
		button_table[8][2] = (Button)findViewById(R.id.gameButton93);
		button_table[8][3] = (Button)findViewById(R.id.gameButton94);
		button_table[8][4] = (Button)findViewById(R.id.gameButton95);
		button_table[8][5] = (Button)findViewById(R.id.gameButton96);
		button_table[8][6] = (Button)findViewById(R.id.gameButton97);
		button_table[8][7] = (Button)findViewById(R.id.gameButton98);
		button_table[8][8] = (Button)findViewById(R.id.gameButton99);
	}
	public void make_layout_table()
	{
		layout_table.l_1 = (LinearLayout)findViewById(R.id.gameLinearLayout1);
			layout_table.l_11 = (LinearLayout)findViewById(R.id.gameLinearLayout11);
			layout_table.l_12 = (LinearLayout)findViewById(R.id.gameLinearLayout12);
			layout_table.l_13 = (LinearLayout)findViewById(R.id.gameLinearLayout13);
		layout_table.l_2 = (LinearLayout)findViewById(R.id.gameLinearLayout2);
		layout_table.l_3 = (LinearLayout)findViewById(R.id.gameLinearLayout3);
	}
	public void setup_button()
	{
		Display d = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
		int w = d.getWidth();
		button_table[0][0].setText("");
		button_table[0][0].setWidth(w/9);
		button_table[0][0].setHeight(w/9);
	}
}
class layout_table
{//布局表
 //缩进为了阅读方便
 //1/3位表示水平布局，2位表示垂直布局
	public static LinearLayout l_1 = null;
		public static LinearLayout l_11 = null;
			public static LinearLayout l_111 = null;
			public static LinearLayout l_112 = null;
			public static LinearLayout l_113 = null;
		public static LinearLayout l_12 = null;
			public static LinearLayout l_121 = null;
			public static LinearLayout l_122 = null;
			public static LinearLayout l_123 = null;
		public static LinearLayout l_13 = null;
			public static LinearLayout l_131 = null;
			public static LinearLayout l_132 = null;
			public static LinearLayout l_133 = null;
	public static LinearLayout l_2 = null;
		public static LinearLayout l_21 = null;
			public static LinearLayout l_211 = null;
			public static LinearLayout l_212 = null;
			public static LinearLayout l_213 = null;
		public static LinearLayout l_22 = null;
			public static LinearLayout l_221 = null;
			public static LinearLayout l_222 = null;
			public static LinearLayout l_223 = null;
		public static LinearLayout l_23 = null;
			public static LinearLayout l_231 = null;
			public static LinearLayout l_232 = null;
			public static LinearLayout l_233 = null;
	public static LinearLayout l_3 = null;
		public static LinearLayout l_31 = null;
			public static LinearLayout l_311 = null;
			public static LinearLayout l_312 = null;
			public static LinearLayout l_313 = null;
		public static LinearLayout l_32 = null;
			public static LinearLayout l_321 = null;
			public static LinearLayout l_322 = null;
			public static LinearLayout l_323 = null;
		public static LinearLayout l_33 = null;
			public static LinearLayout l_331 = null;
			public static LinearLayout l_332 = null;
			public static LinearLayout l_333 = null;
}
